package com.soft.javase.day02.practice.game;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/16
 */
public class Test {
    public static void main(String[] args) {

        Hero hero = new Hero("亚连", 10, 100, 20, 15, "人类");

        Equip sword = new Equip("勇者之剑", 5, "白色", "武器", 15, 5);
        Equip armor = new Equip("冰霜铠甲", 5, "蓝色", "防具", 0, 20);
        Equip shield = new Equip("龙鳞盾", 5, "银色", "防具", 5, 15);

        hero.addEquip(sword);
        hero.addEquip(armor);
        hero.addEquip(shield);

        Monster monster = new Monster("九头蛇", 15, 150, 80, 20, "蛇族");

        hero.show();
        System.out.println("------------------------");
        monster.show();
        System.out.println("------------------------");

        System.out.println("战斗开始！");
        int round = 1;

        while (!hero.isDead() && !monster.isDead()) {
            System.out.println("\n=== 第 " + round + " 回合 ===");

            // 英雄攻击
            hero.attack(monster);
            if (monster.isDead()) {
                System.out.println(monster.getName() + " 已被击败！");
                break;
            }

            // 怪兽攻击
            monster.attack(hero);
            if (hero.isDead()) {
                System.out.println(hero.getName() + " 已被击败！");
                break;
            }

            round++;
        }

        System.out.println("\n战斗结束！");
        if (hero.isDead()) {
            System.out.println(monster.getName() + " 获得了胜利！");
        } else {
            System.out.println(hero.getName() + " 获得了胜利！");
        }
    }
}
